#!/bin/bash

# 本地目录
LocalDir=$(pwd)
echo "The current dir is: $LocalDir"

# 需要传输的文件
ftpFile=$1
if [ ! -f $1 ]; then
    echo "we need the file from ftp!"
    echo "**usage**:  ftpput <filename> [binary]"
    exit 2
fi

# 传输的模式
TransMode='binary'
if [ "x$2" == "xascii" ]; then
    TransMode='ascii'
fi

ftp -n<<!
open 192.168.1.25
user yongfu mypass
$TransMode
cd /
lcd $LocalDir
prompt
put $ftpFile $ftpFile
close
bye
!
